from time import sleep

from appium.webdriver.common.appiumby import AppiumBy

from appium_xueqiu.page_object.base_page.base_page import BasePage
from appium_xueqiu.page_object.classification_page import ClassificationPage


class SearchPage(BasePage):

    __SEARCH_INPUT = (AppiumBy.ID, "com.xueqiu.android:id/search_input_text")

    def input_send_key(self, context):
        self.do_click(self.__SEARCH_INPUT).do_send_keys(context, self.__SEARCH_INPUT)

        return self

    def select_click(self, stock_name):
        self.do_select_click(0, (AppiumBy.XPATH, f"//*[@text='{stock_name}']/../..//*[@class='android.widget.LinearLayout']"))

        return ClassificationPage(self.driver)